Imports Microsoft.VisualBasic

Public Class ContentArea
    Inherits System.Web.UI.UserControl

    Private _contentKey As String
    Private _contentTitle As String
    Protected _pageName As String
    Protected _dbConnection As IDataStore

    Public Property ContentKey() As String
        Get
            Return _contentKey.ToLower
        End Get
        Set(ByVal value As String)
            _contentKey = value
        End Set
    End Property

    Public Property ContentTitle() As String

        Get
            Return _contentTitle
        End Get
        Set(ByVal value As String)
            _contentTitle = value
        End Set

    End Property

    Public Sub RemotePublish()

        _dbConnection.PublishContent()

    End Sub

    Public Property PageName() As String
        Get
            Return _pageName
        End Get
        Set(ByVal value As String)
            _pageName = value
        End Set
    End Property

    Public Function GetPageName() As String

        Dim segments As Integer
        segments = Request.Url.Segments.Length

        If Not segments = 0 Then

            Dim lastSegment As Integer
            lastSegment = segments - 1

            Dim stringSegment As String
            stringSegment = Request.Url.Segments(lastSegment).ToLower

            _pageName = stringSegment.Replace(".aspx", "")

        End If

        Return _pageName

    End Function

    Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        _dbConnection = New XmlManipulator(_pageName)
        _dbConnection.ContentKey = Me.ContentKey

    End Sub

End Class
